# Maintainer: Daniel Fancsali <fancsali@gmail.com>
pkgname=gpsbabel
pkgver=1.8.0
pkgrel=5
pkgdesc="Convert, manipulate, and transfer data from GPS programs or GPS receivers"
url="https://www.gpsbabel.org/"
# armv7: qt5-qtwebengine disabled in b3b11fab054468f565777d32493039fe901fcef3
arch="aarch64 x86_64"
license="GPL-2.0-or-later"
makedepends="
	cmake
	libusb-dev
	qt5-qtserialport-dev
	qt5-qttools-dev
	qt5-qtwebchannel-dev
	qt5-qtwebengine-dev
	samurai
	shapelib-dev
	zlib-dev
	"
checkdepends="diffutils"
subpackages="$pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/GPSBabel/gpsbabel/archive/refs/tags/gpsbabel_${pkgver//./_}.tar.gz"
builddir="$srcdir/gpsbabel-gpsbabel_${pkgver//./_}"

build() {
	CFLAGS="$CFLAGS -flto=auto -O2" \
	CXXFLAGS="$CXXFLAGS -flto=auto -O2" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DGPSBABEL_WITH_ZLIB=pkgconfig \
		-DGPSBABEL_WITH_SHAPELIB=pkgconfig \
		-DGPSBABEL_WITH_LIBUSB=pkgconfig \
		-DQT_VERSION_MAJOR=6
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure -j${JOBS:-2}
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# XXX: the above doesn't install anything (broken)
	install -Dm755 build/gpsbabel build/gui/GPSBabelFE/gpsbabelfe -t "$pkgdir"/usr/bin
	install -Dm644 gui/*.qm gui/coretool/*.qm -t "$pkgdir"/usr/share/gpsbabel/translations
	install -Dm644 gui/gmapbase.html -t "$pkgdir"/usr/share/gpsbabel
	install -Dm644 gui/gpsbabel.desktop -t "$pkgdir"/usr/share/applications
}

lang() {
	pkgdesc="translations for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel lang"

	amove usr/share/gpsbabel/translations
}

sha512sums="
93137586cf887e185d96f06f59be4456cf9bae976979b9e5caad6ae8017c148d4c4c0fc182e8bd4c8547c3ed040c46f74e6f3cfb5f7b566d54fbc7fd767e27e4  gpsbabel-1.8.0.tar.gz
"
